package com.zh;
import java.util.ArrayList;
import java.util.Scanner;
/**
 * @description:
 * @author: zhangHang
 * @date: Created in 2020/3/29 8:55
 * @version: 1.0
 * @modified By:
 */
public class Ui {
    public static void menuMain(){
        System.out.println("--------------------------------");
        System.out.println("-1.browse data                 -");
        System.out.println("-2.js data");
        System.out.println("-3.exit                        -");
        System.out.println("--------------------------------");
        System.out.println("please choice:");
    }
    public static void menuJs(){
        System.out.println("--------------------------------");
        System.out.println("-1.major                       -");
        System.out.println("-2.class");
        System.out.println("-3.back                        -");
        System.out.println("--------------------------------");
        System.out.println("please choice:");
    }
    public static void browseStudentSet (ArrayList<StudentRecord> set){
        System.out.println("\t\t\t\t\t\t");
        for (StudentRecord item : set){
            System.out.print(item.getA()+"\t\t");
            System.out.print(item.getB()+"\t\t");
            System.out.println(item.getC());
        }
    }

    public static int getUserOrder(){
        Scanner scanner = new Scanner(System.in);
        return scanner.nextInt();
    }
    public static String getParameter() {
        Scanner scanner = new Scanner(System.in);
        return scanner.nextLine();
    }
    public static void js(ArrayList<StudentRecord> set){
        int i=0;
        float fail=0;
        float sum=0;
//        String a1="class";
//        String a2="studentNumber";
//        String a3="totalScore";
//        String a4="failRate";
//        String a5="averageScore";
//        System.out.println("class"+"\t\t\t\t\t"+"studentsNumber"+"\t\t"+"totalScore"+"\t\t"+"failRate"+"\t"+"averageScore");
//        System.out.format("%-16s%-16s%%-16s%-16s%%-16s%\n",a1,a2,a3,a4,a5);
        String temp;
        temp=set.get(i).getA();

        for (i=0;i<set.size();i++){
            if(set.get(i).getA().equals(temp)){
                fail+=Integer.parseInt(set.get(i).getD());
                sum+=Float.parseFloat(set.get(i).getC());
                if(i==set.size()-1){
//                    System.out.println(set.get(i-1).getA()+"\t\t"+set.get(i-1).getB()+"\t\t\t\t\t"+sum+
//                            "\t\t"+fail/Integer.parseInt(set.get(i-1).getB())+"\t\t\t"+
//                            sum/Integer.parseInt(set.get(i-1).getB()));
                    System.out.format("%-20s%-20s%-20.2f%-20.4f%-20.2f\n",set.get(i-1).getA(),set.get(i-1).getB(),sum,
                            fail/Integer.parseInt(set.get(i-1).getB()),sum/Integer.parseInt(set.get(i-1).getB()));
                }
            }
            else {
//                System.out.println(set.get(i-1).getA()+"\t\t"+set.get(i-1).getB()+"\t\t\t\t\t"+sum+
//                        "\t\t"+fail/Integer.parseInt(set.get(i-1).getB())+"\t\t\t"+
//                        sum/Integer.parseInt(set.get(i-1).getB()));
                System.out.format("%-20s%-20s%-20.2f%-20.4f%-20.2f\n",set.get(i-1).getA(),set.get(i-1).getB(),sum,
                        fail/Integer.parseInt(set.get(i-1).getB()),sum/Integer.parseInt(set.get(i-1).getB()));


                fail=0;
                sum=0;
                temp=set.get(i).getA();
                i=i-1;
            }

        }
    }


}
